<template>
  <div>
    <el-form label-width="120px">
      <el-form-item label="昵称">
        <el-input v-model="userData.name" style="width: 100px;"></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-radio-group v-model="userData.gender">
          <el-radio :label="0">男</el-radio>
          <el-radio :label="1">女</el-radio>
          <el-radio :label="2">保密</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="生日">
        <el-radio-group>
          <el-date-picker
            v-model="userData.birthday"
            type="date"
            placeholder="请选择"
            format="YYYY/MM/DD"
          />
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button color="#3271ae" @click="doUserUpdate">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { userinfo, userUpdate } from "@/api/user";
import { ElMessage } from 'element-plus';

export default {
  data() {
    return {
      userData: {}
    }
  },
  methods: {
    doUserinfo() {
      userinfo().then(res => {
        this.userData = res
      })
    },
    doUserUpdate() {
      userUpdate(this.userData).then(res => [
        ElMessage.success("更新成功")
      ])
    }
  },
  created() {
    this.doUserinfo()
  }
};
</script>